home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / libx11 / include / x11 / xmu / editresp.h < prev    next >
C/C++ Source or Header  |  1999-01-01  |  7KB  |  294 lines

  1. /*
  2.  * $XConsortium: EditresP.h,v 1.11 91/07/30 15:28:28 rws Exp $
  3.  *
  4.  * Copyright 1989 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  * Author:  Chris D. Peterson, MIT X Consortium
  24.  */
  25.  
  26. /************************************************************
  27.  
  28.         The Editres Protocol
  29.  
  30.  
  31.   The Client message sent to the application is:
  32.  
  33.   ATOM = "ResEditor"         --- RES_EDITOR_NAME
  34.  
  35.   FORMAT = 32                   --- RES_EDIT_SEND_EVENT_FORMAT
  36.  
  37.   l[0] = timestamp
  38.   l[1] = command atom name
  39.   l[2] = ident of command.
  40.   l[3] = protocol version number to use.
  41.  
  42.  
  43.  
  44.   The binary protocol has the following format:
  45.  
  46.     Card8:        8-bit unsingned integer
  47.     Card16:        16-bit unsingned integer
  48.     Card32:        32-bit unsingned integer
  49.     Int16:        16-bit signed integer
  50.     Window:        32-bit value
  51.     Widget:        32-bit value
  52.     String8:        ListOfCard8
  53.     
  54.     [a][b][c] represent an exclusive list of choices.
  55.  
  56.     All widgets are passed as a list of widgets, containing the 
  57.     full instance heirarch of this widget.  The hierarchy is ordered
  58.     from parent to child.  Thus the first element of each list is
  59.     the root of the widget tree (this makes verifying that the widget
  60.     still exists, MUCH faster).
  61.  
  62.     ListOfFoo comprises a list of things in the following format:
  63.     
  64.     number:            Card16
  65.     <number> things:    ????
  66.     
  67.   This is a synchronous protocol, every request MUST be followed by a
  68.   reply.  
  69.  
  70.   Request:
  71.  
  72.     Serial Number:    Card8
  73.     Op Code:    Card8 -    { SendWidgetTree = 0,
  74.                   SetValues = 1,
  75.                   GetResources = 2,
  76.                   GetGeometry = 3,
  77.                   FindChild = 4 }
  78.     Length:        Card32
  79.     Data:        
  80.  
  81.    Reply:
  82.  
  83.     Serial Number:    Card8
  84.     Type:        Card8 - { Formatted = 0,
  85.                               Unformatted = 1,
  86.                   ProtocolMismatch = 2
  87.                 }
  88.     Length:        Card32
  89.  
  90.  
  91.    Byte Order:
  92.  
  93.     All Fields are MSB -> LSB
  94.  
  95.     Data:
  96.  
  97.         Formatted:
  98.  
  99.             The data contains the reply information for the request as
  100.         specified below if the reply type is "Formatted".  The return
  101.         values for the other reply types are shown below.
  102.  
  103.         Unformatted:
  104.  
  105.         Message:    String8
  106.  
  107.     ProtocolMismatch:
  108.  
  109.         RequestedVersion:       Card8
  110.  
  111. ------------------------------------------------------------
  112.  
  113.    SendWidgetTree:
  114.  
  115.     --->
  116.  
  117.     Number of Entries:    Card16
  118.     Entry:
  119.         widget:        ListOfWidgets
  120.         name:        String8
  121.         class:        String8
  122.         window:        Card32
  123.  
  124.     Send Widget Tree returns the fully specified list of widgets
  125.     for each widget in the tree.  This is enough information to completely
  126.     reconstruct the entire widget heirarchy.
  127.  
  128.     The window return value contains the Xid of the window currently 
  129.     used by this widget.  If the widget is unrealized then 0 is returned,
  130.     and if widget is a non-windowed object a value of 2 is returned.
  131.  
  132.    SetValues:
  133.  
  134.     name:    String8
  135.     type:    String8
  136.     value:  String8
  137.     Number of Entries:    Card16
  138.     Entry:
  139.         widget:        ListOfWidgets
  140.  
  141.     --->
  142.  
  143.     Number of Entries:    Card16
  144.     Entry:
  145.         widget:        ListOfWidgets
  146.         message:    String8
  147.  
  148.     SetValues will allow the same resource to be set on a number of 
  149.     widgets.  This function will return an error message if the SetValues
  150.     request caused an Xt error.
  151.     
  152.    GetResources:
  153.  
  154.     Number of Entries:    Card16
  155.     Entry
  156.         widget:        ListOfWidgets:
  157.  
  158.     ---->
  159.  
  160.     Number of Entries:    Card16
  161.     Entry
  162.         Widget:            ListOfWidgets:
  163.         Error:            Bool
  164.  
  165.         [ Message:        String 8 ]
  166.         [ Number of Resources:    Card16
  167.         Resource:
  168.             Kind:    {normal, constraint}
  169.             Name:    String8
  170.             Class:    String8    
  171.             Type:    String8 ]
  172.  
  173.     GetResource retrieves the kind, name, class and type for every 
  174.     widget passed to it.  If an error occured with the resource fetch
  175.     Error will be set to True for the given widget and a message
  176.     is returned rather than the resource info.
  177.  
  178.   GetGeometry:
  179.  
  180.     Number of Entries:    Card16
  181.     Entry
  182.         Widget:        ListOfWidgets:
  183.  
  184.     ---->
  185.  
  186.     Number of Entries:    Card16
  187.     Entry
  188.         Widget:            ListOfWidgets:
  189.         Error:            Bool
  190.  
  191.         [ message:        String 8 ]
  192.         [ mapped:       Boolean
  193.           X:         Int16
  194.           Y:          Int16
  195.           Width:     Card16
  196.                 Height:    Card16
  197.           BorderWidth:    Card16 ]
  198.  
  199.     GetGeometry retreives the mapping state, x, y, width, height
  200.     and border width for each widget specified.  If an error occured 
  201.     with the geometry fetch "Error" will be set to True for the given 
  202.     widget and a message is returned rather than the geometry info.  
  203.     X an Y corrospond to the root coordinates of the upper left corner
  204.     of the widget (outside the window border).
  205.     
  206.   FindChild:
  207.  
  208.     Widget:        ListOfWidgets
  209.     X:        Int16
  210.     Y:        Int16
  211.     
  212.     --->
  213.  
  214.     Widget:        ListOfWidgets
  215.  
  216.     Find Child returns a descendent of the widget specified that 
  217.     is at the root coordinates specified.
  218.  
  219.     NOTE:
  220.  
  221.     The returned widget is undefined if the point is contained in
  222.     two or more mapped widgets, or in two overlapping Rect objs.
  223.  
  224. ************************************************************/
  225.  
  226. #include <X11/Intrinsic.h>
  227. #include <X11/Xfuncproto.h>
  228.  
  229. #define XER_NBBY 8        /* number of bits in a byte */
  230. #define BYTE_MASK 255
  231.  
  232. #define HEADER_SIZE 6
  233.  
  234. #define EDITRES_IS_OBJECT 2
  235. #define EDITRES_IS_UNREALIZED 0
  236.  
  237. /*
  238.  * Format for atoms.
  239.  */
  240.  
  241. #define EDITRES_FORMAT             8
  242. #define EDITRES_SEND_EVENT_FORMAT 32
  243.  
  244. /*
  245.  * Atoms
  246.  */
  247.  
  248. #define EDITRES_NAME         "Editres"
  249. #define EDITRES_COMMAND_ATOM "EditresCommand"
  250. #define EDITRES_COMM_ATOM    "EditresComm"
  251. #define EDITRES_CLIENT_VALUE "EditresClientVal"
  252. #define EDITRES_PROTOCOL_ATOM "EditresProtocol"
  253.  
  254. typedef enum { SendWidgetTree = 0, SetValues = 1, GetResources = 2,
  255.            GetGeometry = 3, FindChild = 4 } EditresCommand;
  256.  
  257. typedef enum {NormalResource = 0, ConstraintResource = 1} ResourceType;
  258.  
  259. /*
  260.  * The type of a resource identifier.
  261.  */
  262.  
  263. typedef unsigned char ResIdent;
  264.  
  265. typedef enum {PartialSuccess= 0, Failure= 1, ProtocolMismatch= 2} EditResError;
  266.  
  267. typedef struct _WidgetInfo {
  268.     unsigned short num_widgets;
  269.     unsigned long * ids;
  270.     Widget real_widget;
  271. } WidgetInfo;
  272.  
  273. typedef struct _ProtocolStream {
  274.     unsigned long size, alloc;
  275.     unsigned char *real_top, *top, *current;
  276. } ProtocolStream;
  277.  
  278. /************************************************************
  279.  *
  280.  * Function definitions for reading and writing protocol requests.
  281.  *
  282.  ************************************************************/
  283.  
  284. _XFUNCPROTOBEGIN
  285.  
  286. void _XEditResPutString8(), _XEditResPut8(), _XEditResPut16();
  287. void _XEditResPut32(), _XEditResPutWidgetInfo(), _XEditResPutWidget();
  288. void _XEditResResetStream();
  289.  
  290. Boolean _XEditResGet8(), _XEditResGet16(), _XEditResGetSigned16();
  291. Boolean _XEditResGet32(), _XEditResGetString8(), _XEditResGetWidgetInfo();
  292.  
  293. _XFUNCPROTOEND
  294.